#include <iostream>

using namespace std;

class Singleton {
private:
    Singleton() = default;

    ~Singleton() = default;

    Singleton(const Singleton &) = delete;

    const Singleton &operator=(const Singleton &) = delete;

private:
    static Singleton *instance;

    static pthread_mutex_t mutex;

public:
    static Singleton *getInstance() {
        if (instance == nullptr) {
            pthread_mutex_lock(&mutex);
            if (instance == nullptr) {
                instance = new Singleton();
            }
            pthread_mutex_unlock(&mutex);
        }
        return instance;
    }

    static void deleteInstance() {
        delete instance;
        instance = nullptr;
    }
};

Singleton *Singleton::instance = nullptr;

pthread_mutex_t Singleton::mutex = PTHREAD_MUTEX_INITIALIZER;

int main() {
    Singleton *instance = Singleton::getInstance();

    return 0;
}